package com.shiro.freemarker;

import org.apache.shiro.subject.Subject;

public class HasAnyPermissionsTag extends PermissionTag{

	private static final String ROLE_NAMES_DELIMETER = ",";
	
	@Override
	protected boolean showTagBody(String permissions) {
		 boolean hasAnyPermission = false;
	        Subject subject = getSubject();

	        if (subject != null) {
	            for (String permission : permissions.split(ROLE_NAMES_DELIMETER)) {
	                if (isPermitted(permission)) {
	                	hasAnyPermission = true;
	                    break;
	                }
	            }
	        }
	      return hasAnyPermission;
	}
	
}
